<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('会员用户')}</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="user_keys" placeholder="{:lang('请输入手机或昵称')}" value="{$get.user_keys|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('订单单号')}</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="order_no" placeholder="{:lang('请输入订单单号')}" value="{$get.order_no|default=''}">
        </label>
    </div>

    <!--{if $type eq 'a' and !empty($states)}-->
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('售后状态')}</label>
        <label class="layui-input-inline">
            <select class="layui-select" name="status">
                <option value=''>{:lang('- 全部订记录 -')}</option>
                {foreach $states as $k=>$v}
                {if input('status') eq $k.''}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}{/foreach}
            </select>
        </label>
    </div>
    <!--{/if}-->

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('退货原因')}</label>
        <label class="layui-input-inline">
            <select class="layui-select" name="reason">
                <option value=''>{:lang('-- 全部 --')}</option>
                {foreach $reasons as $k=>$v}
                {if input('reason') eq $k.''}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}{/foreach}
            </select>
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">{:lang('申请时间')}</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="create_time" placeholder="{:lang('请选择申请时间')}" value="{$get.create_time|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary" type="submit"><i class="layui-icon">&#xe615;</i> {:lang('搜 索')}</button>
        <button class="layui-btn layui-btn-primary" data-form-export="{:url('index')}?type={$type|default=''}" type="button">
            <i class="layui-icon layui-icon-export"></i> {:lang('导 出')}
        </button>
    </div>
</form>

<script>
    require(['excel'], function (excel) {
        excel.bind(function (data, items) {
            data.forEach(function (order) {
                items.push([
                    order.order_no,
                    order.user.phone,
                    order.user.username || order.user.nickname || '',
                    order.delivery_type ? '{:lang("虚拟商品")}' : '{:lang("实物商品")}',
                    order.payment_trade || '',
                    order.payment_name || order.payment_type || '',
                    order.payment_status ? '{:lang("已支付")}' : '{:lang("未支付")}',
                    order.payment_amount || '0.00',
                    order.payment_time || '',
                ]);
            });

            // 设置表头内容
            items.unshift(['{:lang("订单号")}', '{:lang("用户手机")}', '{:lang("用户姓名")}', '{:lang("订单类型")}', '{:lang("支付单号")}', '{:lang("支付方式")}', '{:lang("支付状态")}', '{:lang("支付金额")}', '{:lang("支付时间")}']);

            // 应用表格样式
            return this.withStyle(items, {I: 120});

        }, '{:lang("用户订单记录")}' + layui.util.toDateString(Date.now(), '_yyyyMMdd_HHmmss'));
    });
</script>